//
//  AllCollectionViewCell.m
//  AILove
//
//  Created by 甘世清 on 2023/12/28.
//

#import "AllCollectionViewCell.h"

@implementation AllCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.contentView.backgroundColor = UIColor.clearColor;
        [self.contentView addSubview:self.headerView];
        [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(10, 10, 40, 10));
        }];
        [self.contentView addSubview:self.nameLabel];
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.contentView);
            make.top.equalTo(self.headerView.mas_bottom).offset(10);
        }];
    }
    return self;
}

- (void)setModel:(PeopleModel *)model{
    _model = model;
    [self.headerView sd_setImageWithURL:SQURLImage(model.cover)];
    self.nameLabel.text = model.name;
}


- (UIImageView *)headerView{
    if (!_headerView) {
        _headerView = [[UIImageView alloc]init];
        _headerView.contentMode = UIViewContentModeScaleAspectFill;
        _headerView.layer.cornerRadius = 8;
        _headerView.layer.masksToBounds = YES;
        _headerView.clipsToBounds = YES;
    }
    return _headerView;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = FONT_MEDIUM(16);
        _nameLabel.textColor =  SQColor(@"#A4A4A5");
        _nameLabel.backgroundColor = UIColor.clearColor;
        _nameLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _nameLabel;
}
@end
